/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package EntidadesBD;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author ROCIO
 */
@Entity
@Table(name = "persona", catalog = "secdux", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Persona.findAll", query = "SELECT p FROM Persona p"),
    @NamedQuery(name = "Persona.findByCedula", query = "SELECT p FROM Persona p WHERE p.cedula = :cedula"),
    @NamedQuery(name = "Persona.findByNombre", query = "SELECT p FROM Persona p WHERE p.nombre = :nombre"),
    @NamedQuery(name = "Persona.findByApellido", query = "SELECT p FROM Persona p WHERE p.apellido = :apellido"),
    @NamedQuery(name = "Persona.findByDireccion", query = "SELECT p FROM Persona p WHERE p.direccion = :direccion"),
    @NamedQuery(name = "Persona.findByTelefono", query = "SELECT p FROM Persona p WHERE p.telefono = :telefono"),
    @NamedQuery(name = "Persona.findByFechaNacimiento", query = "SELECT p FROM Persona p WHERE p.fechaNacimiento = :fechaNacimiento"),
    @NamedQuery(name = "Persona.findByLibreta", query = "SELECT p FROM Persona p WHERE p.libreta = :libreta"),
    @NamedQuery(name = "Persona.findByHijos", query = "SELECT p FROM Persona p WHERE p.hijos = :hijos"),
    @NamedQuery(name = "Persona.findByEstadoCivil", query = "SELECT p FROM Persona p WHERE p.estadoCivil = :estadoCivil"),
    @NamedQuery(name = "Persona.findBySexo", query = "SELECT p FROM Persona p WHERE p.sexo = :sexo"),
    @NamedQuery(name = "Persona.findByEstado", query = "SELECT p FROM Persona p WHERE p.estado = :estado"),
    @NamedQuery(name = "Persona.findByFechaExpCedula", query = "SELECT p FROM Persona p WHERE p.fechaExpCedula = :fechaExpCedula"),
    @NamedQuery(name = "Persona.findByTipoSangre", query = "SELECT p FROM Persona p WHERE p.tipoSangre = :tipoSangre"),
    @NamedQuery(name = "Persona.findByNivelEstudio", query = "SELECT p FROM Persona p WHERE p.nivelEstudio = :nivelEstudio"),
    @NamedQuery(name = "Persona.findByHojaDeVida", query = "SELECT p FROM Persona p WHERE p.hojaDeVida = :hojaDeVida"),
    @NamedQuery(name = "Persona.findBySoportes", query = "SELECT p FROM Persona p WHERE p.soportes = :soportes"),
    @NamedQuery(name = "Persona.findByTargetaProfesional", query = "SELECT p FROM Persona p WHERE p.targetaProfesional = :targetaProfesional"),
    @NamedQuery(name = "Persona.findByExamenesMedicos", query = "SELECT p FROM Persona p WHERE p.examenesMedicos = :examenesMedicos"),
    @NamedQuery(name = "Persona.findByRut", query = "SELECT p FROM Persona p WHERE p.rut = :rut"),
    @NamedQuery(name = "Persona.findByNumeroDeFolios", query = "SELECT p FROM Persona p WHERE p.numeroDeFolios = :numeroDeFolios")})
public class Persona implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "Cedula", nullable = false)
    private Long cedula;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "Nombre", nullable = false, length = 50)
    private String nombre;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "Apellido", nullable = false, length = 50)
    private String apellido;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "Direccion", nullable = false, length = 50)
    private String direccion;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 14)
    @Column(name = "Telefono", nullable = false, length = 14)
    private String telefono;
    @Basic(optional = false)
    @NotNull
    @Column(name = "FechaNacimiento", nullable = false)
    @Temporal(TemporalType.DATE)
    private Date fechaNacimiento;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Libreta", nullable = false)
    private long libreta;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Hijos", nullable = false)
    private int hijos;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 12)
    @Column(name = "EstadoCivil", nullable = false, length = 12)
    private String estadoCivil;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 1)
    @Column(name = "Sexo", nullable = false, length = 1)
    private String sexo;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Estado", nullable = false)
    private int estado;
    @Basic(optional = false)
    @NotNull
    @Column(name = "FechaExpCedula", nullable = false)
    @Temporal(TemporalType.DATE)
    private Date fechaExpCedula;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 3)
    @Column(name = "TipoSangre", nullable = false, length = 3)
    private String tipoSangre;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "NivelEstudio", nullable = false, length = 45)
    private String nivelEstudio;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2)
    @Column(name = "HojaDeVida", nullable = false, length = 2)
    private String hojaDeVida;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2)
    @Column(name = "Soportes", nullable = false, length = 2)
    private String soportes;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2)
    @Column(name = "TargetaProfesional", nullable = false, length = 2)
    private String targetaProfesional;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2)
    @Column(name = "ExamenesMedicos", nullable = false, length = 2)
    private String examenesMedicos;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2)
    @Column(name = "Rut", nullable = false, length = 2)
    private String rut;
    @Basic(optional = false)
    @NotNull
    @Column(name = "NumeroDeFolios", nullable = false)
    private int numeroDeFolios;
    @JoinColumn(name = "Pais", referencedColumnName = "idPais", nullable = false)
    @ManyToOne(optional = false)
    private Pais pais;
    @JoinColumn(name = "DepartExpCedula", referencedColumnName = "idDepartamento", nullable = false)
    @ManyToOne(optional = false)
    private Departamento departExpCedula;
    @JoinColumn(name = "LugarExpCedula", referencedColumnName = "idLugar", nullable = false)
    @ManyToOne(optional = false)
    private Lugar lugarExpCedula;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cedula")
    private List<Contrato> contratoList;

    public Persona() {
    }

    public Persona(Long cedula) {
        this.cedula = cedula;
    }

    public Persona(Long cedula, String nombre, String apellido, String direccion, String telefono, Date fechaNacimiento, long libreta, int hijos, String estadoCivil, String sexo, int estado, Date fechaExpCedula, String tipoSangre, String nivelEstudio, String hojaDeVida, String soportes, String targetaProfesional, String examenesMedicos, String rut, int numeroDeFolios) {
        this.cedula = cedula;
        this.nombre = nombre;
        this.apellido = apellido;
        this.direccion = direccion;
        this.telefono = telefono;
        this.fechaNacimiento = fechaNacimiento;
        this.libreta = libreta;
        this.hijos = hijos;
        this.estadoCivil = estadoCivil;
        this.sexo = sexo;
        this.estado = estado;
        this.fechaExpCedula = fechaExpCedula;
        this.tipoSangre = tipoSangre;
        this.nivelEstudio = nivelEstudio;
        this.hojaDeVida = hojaDeVida;
        this.soportes = soportes;
        this.targetaProfesional = targetaProfesional;
        this.examenesMedicos = examenesMedicos;
        this.rut = rut;
        this.numeroDeFolios = numeroDeFolios;
    }

    public Long getCedula() {
        return cedula;
    }

    public void setCedula(Long cedula) {
        this.cedula = cedula;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getApellido() {
        return apellido;
    }

    public void setApellido(String apellido) {
        this.apellido = apellido;
    }

    public String getDireccion() {
        return direccion;
    }

    public void setDireccion(String direccion) {
        this.direccion = direccion;
    }

    public String getTelefono() {
        return telefono;
    }

    public void setTelefono(String telefono) {
        this.telefono = telefono;
    }

    public Date getFechaNacimiento() {
        return fechaNacimiento;
    }

    public void setFechaNacimiento(Date fechaNacimiento) {
        this.fechaNacimiento = fechaNacimiento;
    }

    public long getLibreta() {
        return libreta;
    }

    public void setLibreta(long libreta) {
        this.libreta = libreta;
    }

    public int getHijos() {
        return hijos;
    }

    public void setHijos(int hijos) {
        this.hijos = hijos;
    }

    public String getEstadoCivil() {
        return estadoCivil;
    }

    public void setEstadoCivil(String estadoCivil) {
        this.estadoCivil = estadoCivil;
    }

    public String getSexo() {
        return sexo;
    }

    public void setSexo(String sexo) {
        this.sexo = sexo;
    }

    public int getEstado() {
        return estado;
    }

    public void setEstado(int estado) {
        this.estado = estado;
    }

    public Date getFechaExpCedula() {
        return fechaExpCedula;
    }

    public void setFechaExpCedula(Date fechaExpCedula) {
        this.fechaExpCedula = fechaExpCedula;
    }

    public String getTipoSangre() {
        return tipoSangre;
    }

    public void setTipoSangre(String tipoSangre) {
        this.tipoSangre = tipoSangre;
    }

    public String getNivelEstudio() {
        return nivelEstudio;
    }

    public void setNivelEstudio(String nivelEstudio) {
        this.nivelEstudio = nivelEstudio;
    }

    public String getHojaDeVida() {
        return hojaDeVida;
    }

    public void setHojaDeVida(String hojaDeVida) {
        this.hojaDeVida = hojaDeVida;
    }

    public String getSoportes() {
        return soportes;
    }

    public void setSoportes(String soportes) {
        this.soportes = soportes;
    }

    public String getTargetaProfesional() {
        return targetaProfesional;
    }

    public void setTargetaProfesional(String targetaProfesional) {
        this.targetaProfesional = targetaProfesional;
    }

    public String getExamenesMedicos() {
        return examenesMedicos;
    }

    public void setExamenesMedicos(String examenesMedicos) {
        this.examenesMedicos = examenesMedicos;
    }

    public String getRut() {
        return rut;
    }

    public void setRut(String rut) {
        this.rut = rut;
    }

    public int getNumeroDeFolios() {
        return numeroDeFolios;
    }

    public void setNumeroDeFolios(int numeroDeFolios) {
        this.numeroDeFolios = numeroDeFolios;
    }

    public Pais getPais() {
        return pais;
    }

    public void setPais(Pais pais) {
        this.pais = pais;
    }

    public Departamento getDepartExpCedula() {
        return departExpCedula;
    }

    public void setDepartExpCedula(Departamento departExpCedula) {
        this.departExpCedula = departExpCedula;
    }

    public Lugar getLugarExpCedula() {
        return lugarExpCedula;
    }

    public void setLugarExpCedula(Lugar lugarExpCedula) {
        this.lugarExpCedula = lugarExpCedula;
    }

    @XmlTransient
    public List<Contrato> getContratoList() {
        return contratoList;
    }

    public void setContratoList(List<Contrato> contratoList) {
        this.contratoList = contratoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cedula != null ? cedula.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Persona)) {
            return false;
        }
        Persona other = (Persona) object;
        if ((this.cedula == null && other.cedula != null) || (this.cedula != null && !this.cedula.equals(other.cedula))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "EntidadesBD.Persona[ cedula=" + cedula + " ]";
    }
    
}
